package handlers

import (
	"book-flag-novel/models"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

func Add(c *gin.Context) {
	depot_code := c.PostForm("depot_code")
	depot_name := c.PostForm("depot_name")
	data := models.Depot{
		Model:     gorm.Model{},
		DepotCode: depot_code,
		DepotName: depot_name,
	}
	err := models.DB.Create(&data)
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	} else {
		c.JSON(200, gin.H{
			"code": 200,
			"msg":  "添加成功",
		})
		return
	}
}
